<template>
  <div class="mine m-contain">
    <div class="top-bg">
      <van-row style="padding:33px 15px auto;">
        <van-col span="5">
          <div>
            <img :src="require('@/assets/image/mine/user.png')"
                 width="60"
                 alt="">
          </div>
        </van-col>
        <van-col span="7">
          <div>
            <p>姓名</p>
            <p class="font-size-13 ">15695236547</p>
          </div>
        </van-col>
        <van-col span="12">
          <div>
            <p class="font-size-10">
              <span>普通会员</span>
              <span class="pull-right">300/500 <img :src="require('@/assets/image/mine/icon-gold.png')"
                     alt=""
                     width="10"></span>
            </p>
            <van-progress class="margin-top-10"
                          :percentage="75"
                          :show-pivot='false'
                          stroke-width="4"
                          pivot-color="#FFD980"
                          color="#FFD980" />
          </div>
        </van-col>
      </van-row>
    </div>
    <div class="top">

      <div class="top-column">
        <van-grid :column-num="3">
          <van-grid-item>
            <p class="num">20</p>
            <p class='title'>主金币</p>
          </van-grid-item>
          <van-grid-item>
            <p class="num">20</p>
            <p class='title'> 子金币</p>
          </van-grid-item>
          <van-grid-item>
            <img width="36"
                 :src="require('@/assets/image/mine/icon-coin-detail.png')"
                 alt="">
            <p class="title font-size-12"
               @click="$router.push('/user/myjinbi')"
               style="color:#333">金币明细 <img :src="require('@/assets/image/mine/icon-2.png')"
                   width="5"
                   alt=""></p>
          </van-grid-item>
        </van-grid>
      </div>
      <van-cell>
        <template #title>
          <span class="custom-title">我的邀请码:
            <span style="font-weight: bold;font-size:18px;padding-left:14px;">NIUBIU</span>
          </span>
        </template>
        <template #right-icon>
          <van-button plain
                      @click="copy"
                      round
                      size="small"
                      type="primary"
                      style="width: 28%;">复制邀请码</van-button>
        </template>
      </van-cell>
    </div>

    <div class="convert">
      <p class="item-title">兑换券</p>
      <van-row gutter="15">
        <van-col span="12">
          <div>
            <img @click="$router.push('/user/exchangecoupon/1')"
                 :src="require('@/assets/image/mine/icon-convert-1.png')"
                 width="100%"
                 alt="">
          </div>
        </van-col>
        <van-col span="12">
          <div>
            <img @click="$router.push('/user/exchangecoupon/2')"
                 :src="require('@/assets/image/mine/icon-convert-2.png')"
                 width="100%"
                 alt="">
          </div>
        </van-col>
      </van-row>
    </div>
    <div class="other">
      <p class="item-title">其他服务</p>
      <div class="div-item"
           @click="$router.push('/user')"
           style="border-top: 1px solid #E6E6E6;">
        <img :src="require('@/assets/image/mine/icon-user.png')"
             width="20"
             alt="">
        <span>个人信息管理</span>
        <img class="pull-right"
             :src="require('@/assets/image/mine/icon-1.png')"
             width="14"
             alt="">
      </div>
      <div class="div-item"
           @click="$router.push('/user/addresslist')">
        <img :src="require('@/assets/image/mine/icon-address.png')"
             width="20"
             alt="">
        <span>收获地址管理</span>
        <img class="pull-right"
             :src="require('@/assets/image/mine/icon-1.png')"
             width="14"
             alt="">
      </div>
      <div class="div-item"
           @click="$router.push('/exchangeRecord')">
        <img :src="require('@/assets/image/mine/icon-record.png')"
             width="20"
             alt="">
        <span>兑换记录</span>
        <img class="pull-right"
             :src="require('@/assets/image/mine/icon-1.png')"
             width="14"
             alt="">
      </div>
      <div class="div-item"
           @click="$router.push('/user/setup')">
        <img :src="require('@/assets/image/mine/icon-set.png')"
             width="20"
             alt="">
        <span>设置</span>
        <img class="pull-right"
             :src="require('@/assets/image/mine/icon-1.png')"
             width="14"
             alt="">
      </div>
    </div>

    <van-tabbar route
                v-model="tabActive"
                active-color="#E62B4B"
                inactive-color="#606266">
      <van-tabbar-item v-for="(item,index) in tabIcon"
                       :key="index"
                       :to="item.path"
                       replace>
        <span>{{item.title}}</span>
        <template #icon="props">
          <img :src="props.active ?item.active : item.inactive" />
        </template>
      </van-tabbar-item>

    </van-tabbar>

  </div>
</template>

<script>
import Vue from 'vue';


import { Button, Cell, CellGroup, Tab, Tabs, Col, Row, Tabbar, TabbarItem, Grid, GridItem, Progress } from 'vant';

Vue.use(Progress);
Vue.use(Grid);
Vue.use(GridItem);
Vue.use(Button);
Vue.use(Col);
Vue.use(Row);
Vue.use(Tab);
Vue.use(Cell);
Vue.use(Tabs);
Vue.use(CellGroup);
Vue.use(Tabbar);
Vue.use(TabbarItem)
export default {
  name: 'Home',
  data() {
    return {
      inviateCode: 'NIUBIU',
      tabActive: 3,
      tabIcon: [
        {
          active: require('@/assets/image/home/icon-home-select.png'),
          inactive: require('@/assets/image/home/icon-home.png'),
          title: '首页',
          path: '/index'
        }, {
          inactive: require('@/assets/image/home/icon-mall.png'),
          active: require('@/assets/image/home/icon-mall-select.png'),
          title: '商城',
          path: '/mall'
        }, {
          inactive: require('@/assets/image/home/icon-cart.png'),
          active: require('@/assets/image/home/icon-cart-select.png'),
          title: '购物车',
          path: '/cart'
        }, {
          inactive: require('@/assets/image/home/icon-mine.png'),
          active: require('@/assets/image/home/icon-mine-select.png'),
          title: '我的',
          path: '/mine'
        }
      ]

    }
  },
  components: {
  },
  methods: {
    copy() {
      var _input = document.createElement("input");   // 直接构建input
      _input.value = this.inviateCode;  // 设置内容
      document.body.appendChild(_input);    // 添加临时实例
      _input.select();   // 选择实例内容
      document.execCommand("Copy");   // 执行复制
      alert('复制成功')
      document.body.removeChild(_input); // 删除临时实例
    }
  }
}
</script>
<style lang="less">
.top-column {
  padding: 14px 0 19px;
  border-bottom: 1px solid #e6e6e6;
}
.van-button--primary {
  width: 80px;
  height: 25px;
  margin-top: 0.375rem;
  border-color: #e62b4b;
  color: #e62b4b !important;
}
.top-bg {
  color: #fff;
  width: 100%;
  height: 12.5rem;
  background: url('./../assets/image/mine/icon-top-bg.png') no-repeat;
  background-size: contain;
  .van-row {
    padding: 0px 15px;
    padding-top: 33px;
    vertical-align: middle;
    .van-col--7 {
      line-height: 24px;
      padding-top: 6px;
    }
    .van-col--12 {
      padding: 20px 16px;
      img {
        vertical-align: -1px;
      }
      .pull-right {
        float: right;
      }
    }
  }
}
.font-size-13 {
  font-size: 13px;
}
.font-size-12 {
  font-size: 12px !important;
}
.font-size-10 {
  font-size: 10px;
}
.mine {
  padding-bottom: 56px;
}
.mine .top {
  height: 133px;
  margin-top: -85px;
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  background-color: #fff;
  border-radius: 10px;
  width: calc(100% - 30px);
  margin: -85px auto;
  margin-bottom: 20px;
  overflow: hidden;
  padding: 0 15px;
  .van-grid-item__content::after {
    border-width: 0 1px 0px 0;
  }
  .van-hairline--top::after {
    border-top: none;
  }
  .van-grid-item__content--center {
    padding: 0px;
    justify-content: end;
    height: 60px;
    .num {
      padding-top: 4px;
      font-size: 17px;
      color: #000;
      font-weight: 600;
    }
    .title {
      position: absolute;
      bottom: 0px;
      color: #000;
      font-size: 15px;
    }
  }
  .van-cell {
    line-height: 40px;
    padding: 0px;
    border-radius: 10px;
  }
}
</style>
<style lang="less" scoped>
.top {
  height: 133px;
  border-radius: 10px;
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
}
.convert {
  padding: 0 15px;
}
.other {
  padding: 0 15px;
  .div-item {
    height: 60px;
    line-height: 60px;
  }
  img {
    vertical-align: -3px;
  }
  .pull-right {
    margin-top: 20px;
    float: right;
  }
  span {
    margin-left: 11px;
    font-size: 15px;
    color: #333333;
  }
}
.item-title {
  margin-top: 25px;
  margin-bottom: 16px;
  font-size: 15px;
  color: #000;
  font-weight: bold;
}
.swiper-tabs {
  height: 56px;
  background-color: #f5f5f5;
}
.product-show {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 60px;
  .van-row {
    margin-top: 10px;
  }
  .pro-title {
    height: 42px;
    line-height: 21px;
    text-align: left;
    font-size: 15px;
    color: #333333;
    overflow-y: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .pro-price {
    margin-top: 6px;
    text-align: left;
    img {
      vertical-align: -3px;
    }
    span {
      color: #e62b4b;
      font-size: 17px;
      padding-left: 4px;
    }
  }
}
.van-tabbar {
  height: 54px;
  border: 1px solid rgba(230, 230, 230, 1);
  .van-tabbar-item__icon img {
    height: 20px;
  }
}
</style>
